﻿using MySql.Data.MySqlClient;
using NB.MGJ.FrameWork;
using NB.MGJ.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NB.MGJ.Service.CodeManage
{
    public class SearchCodeService
    {
        public BaseRepository _baseRepository = new BaseRepository();
        //public PagedList<AntiFake_Digitcode> GetSearchCodeList(ref PagerModel pager, string code)
        //{
        //  StringBuilder strSql1 = new StringBuilder();
        //     strSql1.Append(" ");          
        //         strSql1.Append("a.ButtonId,");
        //         strSql1.Append("a.Fw_Code,");
        //         strSql1.Append("a.Wl_Code,");               
        //         strSql1.Append("a.EnterpriseId,");                        
        //         strSql1.Append("e.EnterpriseName,");
        //         strSql1.Append("e.Code,");                      
        //         var strSql = new StringBuilder(strSql1.ToString().Trim(','));
        //         pager.FldName = strSql.ToString();
        //         pager.TblName = " ";
        //         if (string.IsNullOrEmpty(pager.FldSort) || pager

        //             .FldSort == " ")
        //             pager.FldSort = " a.ButtonId desc ";

        //         MySqlParameter[] parameters = _baseRepository.SqParameterRefactor(ref pager);
        //         IEnumerable<AntiFake_Digitcode> resultList = _baseReposi   tory.ExecuteStoredProcedureCollection<AntiFake_Digitcode>("Common_PageList", parameters);
        //         return new PagedList<AntiFake_Digitcode>(resultList, pager.Page, pager.PageSize, 1, Convert.ToInt32(parameters[6].Value));
        //     }
        public List<AntiFake_Digitcode> GetSearchCodeList(string SearchCode)
        {
            MySqlParameter[] parameters = {
                                              
                                              new MySqlParameter("@SearchCode",SearchCode ),                                            
                                        };
            return _baseRepository.ExecuteStoredProcedureCollection<AntiFake_Digitcode>("PROC_SearchCode", parameters).ToList();
        }

        public List<AntiFake_Digitcode> GetSearchCodeLists(string SearchCode,int ecode)
        {
            MySqlParameter[] parameters = {
                                              new MySqlParameter("@SearchCode",SearchCode),      
                                              new MySqlParameter("@EnterpriseId",ecode)
                                        };
            return _baseRepository.ExecuteStoredProcedureCollection<AntiFake_Digitcode>("PROC_SearchCodes", parameters).ToList();
        }
    }
}
